package gov.pbc.nn.kjgl.software.handle;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.bstek.bdf2.core.business.IUser;
import com.bstek.uflo.client.service.ProcessClient;
import com.bstek.uflo.env.Context;
import com.bstek.uflo.model.ProcessInstance;
import com.bstek.uflo.process.handler.AssignmentHandler;
import com.bstek.uflo.process.node.TaskNode;

import gov.pbc.nn.core.utils.SecurityUtils;
import gov.pbc.nn.kjgl.Constants;

@Component("lxsq.OtherDeptAssignmentHandler")
public class OtherDeptAssignmentHandler implements AssignmentHandler{
	
	@Autowired
	@Qualifier(ProcessClient.BEAN_ID)
	private ProcessClient processClient;
	

	@Override
	public Collection<String> handle(TaskNode taskNode, ProcessInstance processInstance, Context context) {
		// TODO Auto-generated method stub
		String deptId = processClient.getProcessVariable("deptId", processInstance).toString();
		List<String> users = new ArrayList<String>();
		List<IUser> kzUsers = SecurityUtils.getUserByRoleForDept(deptId, Constants.ROLE_LXSHY);
		if (kzUsers.size() > 0) {
			users.add(kzUsers.get(0).getUsername());
		}
		return users;
	}
}
